﻿using System.Collections.Generic;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Furion.DatabaseAccessor;
using Furion.FriendlyException;
using Mapster;
using YShop.Core;
using System.Linq;
using System.Linq.Expressions;
using System;

namespace YShop
{
    /// <summary>
    /// 主从表CURD服务1
    /// </summary>
    /// <typeparam name="TMEntity"></typeparam>
    /// <typeparam name="TSEntity"></typeparam>
    /// <typeparam name="TEntityDto"></typeparam>
    /// <typeparam name="SearchDto"></typeparam>
    /// <typeparam name="ListSearchDto"></typeparam>
    /// <typeparam name="CreateDto"></typeparam>
    /// <typeparam name="UpdateDto"></typeparam>
    public class CrudMasterSlave1Service<TMEntity, TSEntity, TEntityDto, SearchDto, ListSearchDto, CreateDto, UpdateDto> 
        : CrudService<TMEntity,TEntityDto, SearchDto, ListSearchDto, CreateDto, UpdateDto>
        where TMEntity : class, IPrivateEntity, IBaseEntity, new()
        where TSEntity : class, IPrivateEntity, IBaseEntity, new()
        where TEntityDto : class, new()
        where ListSearchDto : PageSearchDto

    {
        private readonly IRepository<TMEntity> _repository;

        public CrudMasterSlave1Service(IRepository<TMEntity> repository) : base(repository)
        {
        }

        //public async new virtual Task<TEntityDto> GetAsync(string id)
        //{
        //    //Expression<Func<TEntity, TSEntity>>
        //    var paramsExp = Expression.Parameter(typeof(TMEntity));
        //    var propName = string.Empty;
        //    typeof(TMEntity).getpro
        //    Expression.PropertyOrField(paramsExp,)
        //    return (await _repository
        //        .Include(s => s.Details, false)
        //        .SingleOrDefaultAsync(s => s.Id == id)
        //        ).Adapt<TEntityDto>();
        //}

        //public async new virtual Task<PagedList<TEntityDto>> GetListAsync(int pageIndex = 1, int pageSize = 20)
        //{
        //    throw new NotImplementedException();
        //}

    }
}
